package com.qf.service.Impl;/*
    Dell
    2021/10/9
    9:25
*/

import com.qf.dao.Impl.UserDaoImpl;
import com.qf.dao.UserDao;
import com.qf.entiy.User;
import com.qf.service.UserService;
import com.qf.util.DruidUtil;

public class UserServiceImpl implements UserService {
    private UserDao userDao = new UserDaoImpl();
    @Override
    public User login(String account, String password) {
        User user = null;
        user = userDao.selectUser(account);
        if(user!=null){
            if(user.getPassword().equals(password)){
                return user;
            }
        }
        DruidUtil.close();
        return null;
    }

    @Override
    public Integer update(String upassword, Integer uid) {
        int i = 0;
        try {
            DruidUtil.begin();
            i = userDao.update(upassword, uid);
            DruidUtil.commit();
        } catch (Exception e) {
            e.printStackTrace();
            DruidUtil.rollback();
        } finally {
            DruidUtil.close();
        }
        return i;
    }
}
